package test.tongcheng58;

import java.util.Arrays;

/**
 * @description:
 * @author: w_jingbo
 * @date: 2023/9/16
 * @Copyright: 博客：http://coisini.wang
 */
public class Main {

    public static void main(String[] args) {
        String source =  "AABC" ;
        String pattern = "AC" ;
        int res = subsequence(source,pattern);
        System.out.println(res);
    }

    public static int subsequence (String source, String pattern) {

        return process(source,pattern,0,0) ;

    }

    public static int process(String source , String pattern , int index1 , int index2){
        if(index2 == pattern.length()){
            return 1 ;
        }
        if(index1 == source.length()){
            return 0 ;
        }
        char c = source.charAt(index1);

        if(c == pattern.charAt(index2)){
            int including = process(source,pattern,index1+1,index2+1) ;
            int excluding = process(source,pattern,index1+1,index2);
            return  including + excluding ;
        }else {
            return  process(source,pattern,index1 + 1 , index2) ;
        }



    }

    public static int calculate (int m, int n, int[] scores) {
        // write code here
        Arrays.sort(scores) ;
        int len = scores.length ;
        if(n * 2 < len){
            return -1 ;
        }
        for (int i = 0; i < len; i++) {
            if((i+1 >= m && i+1 <= n) && (len - i - 1 >= m && len - i - 1 <= n)){
                return scores[i] ;
            }
        }
        return -1;

    }
}
